package com.norra.base.utils

import java.text.SimpleDateFormat
import java.util.*

class TimeUtils {

    companion object {
        fun currentTime(): String {
            val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
            return sdf.format(Date())
        }


        fun parse(timeString: String): Date? {
            return try {
                val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
                sdf.parse(timeString)
            } catch (e: Exception) {
                null
            }
        }

        fun toHourMinute(timeMilli: Long): String? {
            return try {
                val sdf = SimpleDateFormat("HH:mm")
                sdf.format(Date(timeMilli))
            } catch (e: Exception) {
                null
            }
        }
    }

}